﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CodeGeneration.Model
{
    public class CreateConfig
    {
        public CreateConfig()
        {
            ProjectPath = AppDomain.CurrentDomain.BaseDirectory.Substring(
                0,
                AppDomain.CurrentDomain.BaseDirectory.IndexOf("CodeGeneration", StringComparison.Ordinal)
                );
            BLLName = "BLL";
            DALName = "DAL";
            TemplateFilePath = ProjectPath + @"CodeGeneration\Configs\";
            ObjectModelFolder = "Model";
            GenerateClassName = new List<string>();
            IsOverwriteFile = false;
            AssemblyName = DALName;
        }

        public IList<string> GenerateClassName { get; set; }

        /// <summary>
        /// 项目路径
        /// </summary>
        public string ProjectPath { get; set; }

        /// <summary>
        /// DAL路径
        /// </summary>
        public string DALName { get; set; }

        /// <summary>
        /// BLL路径
        /// </summary>
        public string BLLName { get; set; }

        /// <summary>
        /// Interface路径
        /// </summary>
        public string InterfacePath { get; set; }

        /// <summary>
        /// Implement路径
        /// </summary>
        public string ImplementPath { get; set; }

        /// <summary>
        /// 程序集名称
        /// </summary>
        public string AssemblyName { get; set; }

        /// <summary>
        /// 接口文件格式
        /// </summary>
        public string InterfaceFileName
        {
            get
            {
                return string.Format("I{0}", CurrentClassName);
            }
        }

        /// <summary>
        /// 接口实现文件格式
        /// </summary>
        public string ImplementFileName
        {
            get
            {
                return string.Format("{0}IMPL", CurrentClassName);
            }
        }

        /// <summary>
        /// 当前生成的类名
        /// </summary>
        public string CurrentClassName { get; set; }

        /// <summary>
        /// 是否覆盖文件
        /// </summary>
        public bool IsOverwriteFile { get; set; }

        /// <summary>
        /// 模板路径
        /// </summary>
        public string TemplateFilePath { get; set; }

        /// <summary>
        /// 实体类所在的文件夹
        /// </summary>
        public string ObjectModelFolder { get; set; }

        /// <summary>
        /// 需要生成的DbContext
        /// </summary>
        public string DbContextType { get; set; }

        public string PrimaryKey { get; set; }

        public string PrimaryKeyType { get; set; }

        public string InterfaceNamespace { get; set; }

        public string ImplementNamespace { get; set; }

        public string ModelNamespace { get; set; }

        public IList<string> IgnoreClassList { get; set; }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(string.Format("DAL程序集名称：{0};", DALName));
            sb.AppendLine(string.Format("BLL程序集名称：{0};", BLLName));
            sb.AppendLine(string.Format("解决方案目录：{0};", ProjectPath));
            sb.AppendLine(string.Format("是否覆盖已存在文件：{0};", IsOverwriteFile));
            return sb.ToString();
        }

    }
}
